#include <stdio.h>
#include <stdlib.h>

#define N 20
#define M 50

short int pip[N*M] = {0};

int n = 0, m = 0;
int casecount = 0;

void swap(short int* a, short int* b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void sort()
{
    int i = 0, j = 0;

    for(i = m-1; i >= 0; i--)
    {
        for(j = 0; j < i; j++)
        {
            if(pip[j] < pip[j+1])
            {
                swap(&pip[j], &pip[j+1]);
            }
        }
    }

//    for(i = 0; i < m; i++)
//    {
//        printf("%d\t", pip[i]);
//    }
//    printf("\n");
}

void process()
{
    int wincount = 0;
    int i = 0;
    int p0 = 0, nextp = 0;
    sort();

    nextp = m*n;
    for(i = 0; i < m; i++)
    {
        if(nextp == pip[i])
        {
            if(p0 == 0)
            {
                wincount++;
            }
            else
            {
                p0--;
            }
        }
        else
        {
            p0 += (nextp - pip[i]-1);
        }
        nextp = pip[i]-1;
    }

    printf("Case %d: %d\n", ++casecount, wincount);
}

int main()
{
    //freopen("bin\\debug\\in.txt", "r", stdin);
    int i = 0;

    while(1)
    {
        scanf("%d%d", &n, &m);
        if(n == 0 && m == 0)
        {
            break;
        }
        for(i = 0; i < m; i++)
        {
            scanf("%hd", &pip[i]);
        }
        process();
    }

    return 0;
}
